#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
char map[15][15];
int n,m,s;
//标记是否访问过 同时记录从起点到这个点走了多少步
int vis[15][15];
bool check(int r,int c){
    if(r>=0 && r<n && c>=0 && c<m && vis[r][c]!=-1){
        return false;
    }
    else{
        return true;
    }
}
int main(void){
    while(~scanf("%d%d",&n,&m)){
        if(n==0 && m==0){
            break;
        }
        scanf("%d",&s);
        for(int i=0;i<n;i++){
            scanf("%s",map[i]);
        }
        memset(vis,-1,sizeof(vis));
        vis[0][s-1]=0;
        int r=0;
        int c=s-1;
        while(1){
            if((r==n-1 && map[r][c]=='S') ||( c==0 && map[r][c]=='W') || (c==m-1 && map[r][c]=='E') || (r==0 && map[r][c]=='N')){
                printf("%d step(s) to exit\n",vis[r][c]+1);
                break;
            }
            //printf("%d %d %d\n",r,c,vis[r][c]);
            if(map[r][c]=='W'){
                if(check(r,c-1)){
                    c--;
                    vis[r][c]=vis[r][c+1]+1;
                }
                else{
                    printf("%d step(s) before a loop of %d step(s)\n",vis[r][c-1],vis[r][c]-vis[r][c-1]+1);
                    break;
                }
            }
            else if(map[r][c]=='E'){
                if(check(r,c+1)){
                    c++;
                    vis[r][c]=vis[r][c-1]+1;
                }
                else{
                    printf("%d step(s) before a loop of %d step(s)\n",vis[r][c+1],vis[r][c]-vis[r][c+1]+1);
                    break;
                }
            }
            else if(map[r][c]=='N'){
                if(check(r-1,c)){
                    r--;
                    vis[r][c]=vis[r+1][c]+1;
                }
                else{
                    printf("%d step(s) before a loop of %d step(s)\n",vis[r-1][c],vis[r][c]-vis[r-1][c]+1);
                    break;
                }
            }
            else if(map[r][c]=='S'){
                if(check(r+1,c)){
                    r++;
                    vis[r][c]=vis[r-1][c]+1;
                }
                else{
                    printf("%d step(s) before a loop of %d step(s)\n",vis[r+1][c],vis[r][c]-vis[r+1][c]+1);
                    break;
                }
            }
        }
    }
    return 0;
}
